package com.imau.controller;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "ResponseRedirct", value = "/ResponseRedirct")
public class ResponseRedirct extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {


        String userName = request.getParameter("username");
        String password = request.getParameter("password");


        //模拟登录业务  在数据库查询用户名和密码存在 ，跳转到系统后台，不存在重新登录
        if(userName.equals("admin") && password.equals("123456"))
        {

            //重定向 超链接
            response.sendRedirect("/servlet-response1/welcome.html");

        }else {
            //重定向 超链接
            response.sendRedirect("/servlet-response1/login.html");

        }

    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        this.doGet(request,response);
    }
}
